import 'package:flutter/material.dart';

import '../model.dart';

class AnchorCell extends StatefulWidget {
  const AnchorCell({
    super.key,
    required this.mod,
    required this.child,
  });
  final AnchorModel mod;
  final Widget child;
  @override
  State<AnchorCell> createState() => _AnchorCellState();
}

class _AnchorCellState extends State<AnchorCell> {
  late final GlobalKey key = GlobalKey();
  @override
  void initState() {
    super.initState();

    if (!mounted) {
      return;
    }
    WidgetsBinding.instance.addPostFrameCallback((_) {
      widget.mod.getOff(context, key);
    });
  }

  @override
  Widget build(BuildContext context) {
    return SizedBox(
      key: key,
      child: widget.child,
    );
  }
}
